<#-- 注册页 -->
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <base href="${baseURL}" target="_self">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>注册 - ${title}</title>
    <meta name="keywords" content="${keywords}"/>
    <meta name="description" content="${description}"/>
    <link href="${commonPath}css/common.css" type="text/css" rel="stylesheet">
    <link href="${commonPath}css/themify-icons/style.css" type="text/css" rel="stylesheet">
    <script src="${commonPath}js/cryptoJS/core.js" type="text/javascript"></script>
    <script src="${commonPath}js/cryptoJS/sha256.js" type="text/javascript"></script>

    <script src="${commonPath}js/tool.js" type="text/javascript"></script>
    <script src="${commonPath}js/ajax.js" type="text/javascript"></script>
    <script src="${commonPath}js/json2.js" type="text/javascript"></script>
    <script type="text/javascript" src="${commonPath}js/jquery/jquery.min.js"></script>
    <link href="${commonPath}js/layer/skin/default/layer.css" type="text/css" rel="stylesheet"/>
    <script type="text/javascript" src="${commonPath}js/layer/layer.js"></script>
</head>

<body>
<#-- 引入页头 -->
<@include action="${newPublic_2}"/>
<div class="skeleton">
    <div class="main">
        <div class="registerModule">
            <div class="tabs-nav">
                <div>
                    <div id="local_tab"
                         class="tabs-tab" <#if allowRegisterAccount.local != true> style='display: none;'</#if>>
                        <a href="javascript:void(0)" class="active">账号密码注册</a>
                    </div>
                    <div id="mobile_tab"
                         class="tabs-tab" <#if allowRegisterAccount.mobile != true> style='display: none;'</#if>>
                        <a href="javascript:void(0)">手机号注册</a>
                    </div>
                </div>
            </div>
            <div class="box">
                <div class="form">
                    <!-- 令牌标记 -->
                    <input type="hidden" id="token" name="token" value="${token}">
                    <div class="form-field">
                        <!-- form-field-container form-field-error -->
                        <div id="userName_field_error" class="form-field-container">
                            <div class="form-field-text">
                                <div class="form-field-input-container">
                                    <input id="userName" maxLength="40" class="form-field-text-input" type="text"
                                           value="" onfocus="inputBoxClickTip(this);" onblur="inputBoxOutTip(this);">
                                    <!-- <label class="mi-floating-label form-field-active ">用户名</label>-->
                                    <label class="form-field-label">用户名</label>
                                </div>
                            </div>

                            <div id="userName_prompt_error" class="form-field-prompt-error"></div>
                        </div>
                    </div>
                    <div class="form-field">
                        <div id="mobile_field_error" class="form-field-container">
                            <div class="form-field-text">
                                <div class="form-field-input-container">
                                    <input id="mobile" maxLength="11" class="form-field-text-input" type="text" value=""
                                           onfocus="inputBoxClickTip(this);" onblur="inputBoxOutTip(this);">
                                    <label class="form-field-label">手机号</label>
                                </div>
                            </div>
                            <div id="mobile_prompt_error" class="form-field-prompt-error"></div>
                        </div>
                    </div>
                    <div class="form-field">
                        <div id="password_field_error" class="form-field-container">
                            <div class="form-field-text">
                                <div class="form-field-input-container">
                                    <input id="password" maxLength="20" class="form-field-text-input" type="password"
                                           value="" onfocus="inputBoxClickTip(this);" onblur="inputBoxOutTip(this);">
                                    <label class="form-field-label">密码</label>
                                </div>
                            </div>
                            <div id="password_prompt_error" class="form-field-prompt-error"></div>
                        </div>
                    </div>
                    <div class="form-field">
                        <div id="confirmPassword_field_error" class="form-field-container">
                            <div class="form-field-text">
                                <div class="form-field-input-container">
                                    <input id="confirmPassword" maxLength="20" class="form-field-text-input"
                                           type="password" value="" onfocus="inputBoxClickTip(this);"
                                           onblur="inputBoxOutTip(this);">
                                    <label class="form-field-label">确认密码</label>
                                </div>
                            </div>
                            <div id="confirmPassword_prompt_error" class="form-field-prompt-error"></div>
                        </div>
                    </div>
                    <div class="form-field">
                        <div id="issue_field_error" class="form-field-container">
                            <div class="form-field-text">
                                <div class="form-field-input-container">
                                    <input id="issue" maxLength="30" class="form-field-text-input" type="text" value=""
                                           onfocus="inputBoxClickTip(this);" onblur="inputBoxOutTip(this);">
                                    <label class="form-field-label">密码提示问题</label>
                                </div>
                            </div>
                            <div id="issue_prompt_error" class="form-field-prompt-error"></div>
                        </div>
                    </div>
                    <div class="form-field">
                        <div id="answer_field_error" class="form-field-container">
                            <div class="form-field-text">
                                <div class="form-field-input-container">
                                    <input id="answer" maxLength="30" class="form-field-text-input" type="text" value=""
                                           onfocus="inputBoxClickTip(this);" onblur="inputBoxOutTip(this);">
                                    <label class="form-field-label">密码提示答案</label>
                                </div>
                            </div>
                            <div id="answer_prompt_error" class="form-field-prompt-error"></div>
                        </div>
                    </div>
                    <div class="form-field">
                        <div id="email_field_error" class="form-field-container">
                            <div class="form-field-text">
                                <div class="form-field-input-container">
                                    <input id="email" maxLength="30" class="form-field-text-input" type="text" value=""
                                           onfocus="inputBoxClickTip(this);" onblur="inputBoxOutTip(this);">
                                    <label class="form-field-label">邮箱</label>
                                </div>
                            </div>
                            <div id="email_prompt_error" class="form-field-prompt-error"></div>
                            <div class="form-field-help">没有可以不填写</div>
                        </div>
                    </div>

                    <!-- 用户自定义注册功能项 -->
                    <#list userCustomList as userCustom>
                        <#if userCustom.chooseType ==1>
                            <div class="form-field">
                                <div id="userCustom_${userCustom.id}_field_error" class="form-field-container">
                                    <div class="form-field-text">
                                        <div class="form-field-input-container">
                                            <input name="userCustom_${userCustom.id}" size="${userCustom.size}"
                                                   maxlength="${userCustom.maxlength}" class="form-field-text-input"
                                                   type="text"
                                                   value="<#list userCustom.userInputValueList as userInputValue>${userInputValue.content}</#list>"
                                                   onfocus="inputBoxClickTip(this);" onblur="inputBoxOutTip(this);">
                                            <label class="form-field-label"><#if userCustom.required == true><span
                                                        class="required">*</span></#if>${userCustom.name}</label>
                                        </div>
                                    </div>
                                    <div id="userCustom_${userCustom.id}_prompt_error"
                                         class="form-field-prompt-error"></div>
                                    <div class="form-field-help">${userCustom.tip}</div>
                                </div>
                            </div>
                        </#if>
                        <#if userCustom.chooseType ==2>
                            <#if userCustom.itemValue?has_content>
                                <div class="form-field">
                                    <div id="userCustom_${userCustom.id}_field_error" class="form-field-container">
                                        <div class="form-field-radio">
                                            <div class="form-field-radio-container">
                                                <div class="form-field-radio-input">
                                                    <#list userCustom.itemValue?keys as itemValue>
                                                    <#-- 选中项 -->
                                                        <#assign _checked = "">
                                                        <#list userCustom.userInputValueList as userInputValue>
                                                            <#if userInputValue.options == itemValue>
                                                                <#assign _checked=" checked='checked'">
                                                            </#if>
                                                        </#list>

                                                    <#-- 默认选第一项 -->
                                                        <#if itemValue_index == 0  && userCustom.userInputValueList?? && userCustom.userInputValueList?size == 0>
                                                            <#assign _checked = " checked='checked'">
                                                        </#if>

                                                        <label>
                                                            <input type="radio" class="formRadio"
                                                                   name="userCustom_${userCustom.id}"
                                                                   value="${itemValue}" ${_checked}>
                                                            <span class="formRadio-core"></span>
                                                            <span class="formRadio-text">${userCustom.itemValue[itemValue]}</span>
                                                        </label>

                                                    </#list>
                                                </div>
                                                <label class="form-field-label form-field-active"><#if userCustom.required == true>
                                                        <span class="required">*</span></#if>${userCustom.name}</label>
                                            </div>
                                        </div>
                                        <div id="userCustom_${userCustom.id}_prompt_error"
                                             class="form-field-prompt-error"></div>
                                        <div class="form-field-help">${userCustom.tip}</div>
                                    </div>
                                </div>
                            </#if>

                        </#if>
                        <#if userCustom.chooseType ==3>
                            <#if userCustom.itemValue?has_content>
                                <div class="form-field">
                                    <div id="userCustom_${userCustom.id}_field_error" class="form-field-container">
                                        <div class="form-field-radio">
                                            <div class="form-field-radio-container">
                                                <div class="form-field-radio-input">
                                                    <#list userCustom.itemValue?keys as itemValue>
                                                    <#-- 选中项 -->
                                                        <#assign _checked = "">
                                                        <#list userCustom.userInputValueList as userInputValue>
                                                            <#if userInputValue.options == itemValue>
                                                                <#assign _checked=" checked='checked'">
                                                            </#if>
                                                        </#list>
                                                        <label>
                                                            <input type="checkbox" class="formCheckbox"
                                                                   name="userCustom_${userCustom.id}"
                                                                   value="${itemValue}" ${_checked}>
                                                            <span class="formCheckbox-core"></span>
                                                            <span class="formCheckbox-text">${userCustom.itemValue[itemValue]}</span>
                                                        </label>
                                                    </#list>
                                                </div>
                                                <label class="form-field-label form-field-active"><#if userCustom.required == true>
                                                        <span class="required">*</span></#if>${userCustom.name}</label>
                                            </div>
                                        </div>
                                        <div id="userCustom_${userCustom.id}_prompt_error"
                                             class="form-field-prompt-error"></div>
                                        <div class="form-field-help">${userCustom.tip}</div>
                                    </div>
                                </div>
                            </#if>
                        </#if>
                        <#if userCustom.chooseType ==4>
                            <div class="form-field">
                                <div id="userCustom_${userCustom.id}_field_error" class="form-field-container">
                                    <div class="form-field-radio">
                                        <div class="form-field-radio-container">
                                            <div class="form-field-radio-input">
                                                <select class="formSelect"
                                                        name="userCustom_${userCustom.id}" <#if userCustom.multiple == true> multiple='multiple'</#if> <#if userCustom.selete_size != null> size='${userCustom.selete_size}'</#if>>
                                                    <#if userCustom.itemValue?has_content>
                                                        <#list userCustom.itemValue?keys as itemValue>
                                                            <#assign _selected = "">
                                                            <#list userCustom.userInputValueList as userInputValue>
                                                                <#if userInputValue.options == itemValue>
                                                                    <#assign _selected=" selected='selected'">
                                                                </#if>
                                                            </#list>
                                                            <option value="${itemValue}" ${_selected}>${userCustom.itemValue[itemValue]}</option>
                                                        </#list>
                                                    </#if>
                                                </select>
                                            </div>
                                            <label class="form-field-label form-field-active"><#if userCustom.required == true>
                                                    <span class="required">*</span></#if>${userCustom.name}</label>
                                        </div>
                                    </div>
                                    <div id="userCustom_${userCustom.id}_prompt_error"
                                         class="form-field-prompt-error"></div>
                                    <div class="form-field-help">${userCustom.tip}</div>
                                </div>
                            </div>
                        </#if>
                        <#if userCustom.chooseType ==5>
                            <div class="form-field">
                                <div id="userCustom_${userCustom.id}_field_error" class="form-field-container">
                                    <div class="form-field-radio">
                                        <div class="form-field-radio-container">
                                            <div class="form-field-radio-input">
                                                <textarea class="formTextarea" name="userCustom_${userCustom.id}"
                                                          rows="${userCustom.rows}"
                                                          cols="${userCustom.cols}"><#list userCustom.userInputValueList as userInputValue>${userInputValue.content}</#list></textarea>
                                            </div>
                                            <label class="form-field-label form-field-active"><#if userCustom.required == true>
                                                    <span class="required">*</span></#if>${userCustom.name}</label>
                                        </div>
                                    </div>
                                    <div id="userCustom_${userCustom.id}_prompt_error"
                                         class="form-field-prompt-error"></div>
                                    <div class="form-field-help">${userCustom.tip}</div>
                                </div>
                            </div>
                        </#if>
                    </#list>

                    <div class="form-field">
                        <div id="smsCode_field_error" class="form-field-container">
                            <div class="form-field-text">
                                <div class="form-field-input-container">
                                    <input id="smsCode" maxLength="6" class="form-field-text-input" type="text" value=""
                                           onfocus="inputBoxClickTip(this);" onblur="inputBoxOutTip(this);">
                                    <label class="form-field-label">短信验证码</label>
                                </div>
                                <div class="form-field-button-container">
                                    <button type="button" class="btn btn-link" tabindex="-1" onClick="getSmsCode();">
                                        获取验证码
                                    </button>
                                </div>
                            </div>
                            <div id="smsCode_prompt_error" class="form-field-prompt-error"></div>
                            <div id="smsCode_prompt_successInfo" class="form-field-prompt-success"></div>
                        </div>
                    </div>

                    <div id="captchaValue_field" class="form-field" <#if captchaKey == ''>style='display: none;'</#if>>
                        <div id="captchaValue_field_error" class="form-field-container">
                            <div class="form-field-text">
                                <div class="form-field-input-container">
                                    <input type="hidden" id="captchaKey" name="captchaKey" value="${captchaKey}">
                                    <input id="captchaValue" class="form-field-text-input" type="text" maxlength="4"
                                           value="" onfocus="inputBoxClickTip(this);" onblur="inputBoxOutTip(this);">
                                    <label class="form-field-label">验证码</label>
                                </div>
                                <div class="form-field-image-container">
                                    <img id="captcha" src="captcha/${captchaKey!}.jpg" onClick="replaceCaptcha();"
                                         tabindex="4"/>

                                </div>
                                <div class="form-field-button-container" style="background: #fff;">
                                    <button type="button" class="btn btn-link" tabindex="-1"
                                            onClick="replaceCaptcha();">换一幅
                                    </button>
                                </div>
                            </div>
                            <div id="captchaValue_prompt_error" class="form-field-prompt-error"></div>
                        </div>
                    </div>
                </div>
                <div id="token_prompt_error" style="color: red;">${(error['token'])!}</div>
                <div id="type_prompt_error" style="color: red;">${(error['type'])!}</div>
                <div id="register_prompt_error" style="color: red;">${(error['register'])!}</div>

                <div class="otherInfo">
        			<span class="agreement">
						<label>
							<input type="checkbox" class="formCheckbox" name="agreebbrule" checked="checked">
							<span class="formCheckbox-core"></span>
							<span class="formCheckbox-text">同意<a href="agreement.htm" target="_self">网站服务条款</a></span>
						</label>
					</span>
                </div>
                <div class="loginButton">
                    <a href="javascript:void(0);" onClick="javascript:ajaxSubmit()" tabindex="6">注&nbsp;册</a>
                </div>

            </div>

            <div class="prohibitRegister">
                <div class="addAnswer-wrap">
                    <div class="respond">
                        <p>不允许注册</p>
                    </div>
                </div>
            </div>

        </div>

    </div>
</div>
</div>

<script type="text/javascript">
    $(".form-field").find(".form-field-input-container").bind("mousedown", function (e) {
        $(this).find(".form-field-text-input").focus();

        if ($(this).find(".form-field-label").hasClass("form-field-active")) {
            return;

        }
        $(this).find(".form-field-label").addClass("form-field-active");
    });

    $(document).mousedown(function (e) {
        var target = $(e.target);
        if (target.closest(".form-field-input-container").length == 0) {
            $(".form-field-input-container").each(function () {
                if ($(this).find(".form-field-label").hasClass("form-field-active")) {
                    if ($(this).find('input[type="text"]').val() == "" || $(this).find('input[type="password"]').val() == "") {
                        $(this).find(".form-field-label").removeClass("form-field-active");
                    }

                }
            });
        }
    });
    //文本框含有默认值时字段名称缩小
    $(document).ready(function () {
        $(".form-field-input-container").each(function () {
            if (!$(this).find(".form-field-label").hasClass("form-field-active")) {
                if (($(this).find('input[type="text"]').val() != undefined && $(this).find('input[type="text"]').val() != '')
                    || $(this).find('input[type="password"]').val() != undefined && $(this).find('input[type="password"]').val() != '') {
                    $(this).find(".form-field-label").addClass("form-field-active");
                }

            }
        });
    });


    //监听Tab键
    $(document).on('keyup', function (e) {
        if (e.keyCode == 9) {
            var input = $(this).find('input:focus');
            if (input.length) {
                if (!input.parent().parent().find(".form-field-label").hasClass("form-field-active")) {
                    input.parent().parent().find(".form-field-label").addClass("form-field-active");
                }
            }
        }
    });
    //解决提交按钮的click和blur事件冲突
    $(document).ready(function () {
        $("input[type='button']").mousedown(function (e) {
            e.preventDefault();
        });
        $("a[href='javascript:void(0);']").mousedown(function (e) {
            e.preventDefault();
        });

    });
</script>

<script type="text/javascript">
    //选择注册账号类型
    $(document).ready(function () {
        //选择
        $(".tabs-nav").find(".tabs-tab").each(function () {
            if ($(this).find("a").hasClass("active")) {
                selectRegisterAccountType($(this).attr("id"));
            }

            $(this).bind("click", function (e) {
                $(".tabs-nav").find(".tabs-tab").each(function () {
                    $(this).find("a").removeClass("active");
                });
                $(this).find("a").addClass("active");
                selectRegisterAccountType($(this).attr("id"));
            });
        });


        var isTab = false;
        //如果没选择，则默认选第一项
        $(".tabs-nav").find(".tabs-tab").each(function () {
            if (!$(this).is(":hidden") && $(this).find("a").hasClass("active")) {
                isTab = true;
            }

        });
        if (!isTab) {
            $(".tabs-nav").find(".tabs-tab").each(function () {
                $(this).find("a").removeClass("active");
            });
            $(".tabs-nav").find(".tabs-tab").each(function () {
                if (!$(this).is(":hidden")) {
                    $(this).find("a").addClass("active");
                    selectRegisterAccountType($(this).attr("id"));
                    return false;
                }

            });
        }


        var isActive = false;
        $(".tabs-nav").find(".tabs-tab").each(function () {
            if (!$(this).is(":hidden")) {
                isActive = true;
            }

        });
        //如果全部隐藏
        if (!isActive) {
            $(".registerModule").find(".box").hide();
            $(".prohibitRegister").show();
        }


    });

    function selectRegisterAccountType(id) {
        if (id == "local_tab") {//本地账号密码用户
            $("#userName_field_error").parent().show();
            $("#mobile_field_error").parent().hide();
            $("#issue_field_error").parent().show();
            $("#answer_field_error").parent().show();
            $("#email_field_error").parent().show();
            $("#smsCode_field_error").parent().hide();
        }
        if (id == "mobile_tab") {//手机用户
            $("#userName_field_error").parent().hide();
            $("#mobile_field_error").parent().show();
            $("#issue_field_error").parent().hide();
            $("#answer_field_error").parent().hide();
            $("#email_field_error").parent().hide();
            $("#smsCode_field_error").parent().show();
        }
    }


    //点击输入框提示
    function inputBoxClickTip(obj) {


    }

    //离开输入框提示
    function inputBoxOutTip(obj) {
        verification(obj.id);
    }

    //验证参数
    function verification(field) {
        $("#" + field + "_prompt_error").hide();
        $("#" + field + "_field_error").removeClass("form-field-error");

        if (field == "userName") {//用户名
            var userName = $("#" + field).val().trim();
            if (userName == "") {
                $("#" + field + "_prompt_error").html("用户名不能为空");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
            if (getStringLeng(userName) < 3) {
                $("#" + field + "_prompt_error").html("用户名长度不能小于3位");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
            if (getStringLeng(userName) > 20) {
                $("#" + field + "_prompt_error").html("用户名长度不能大于20位");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
            var pattern = /^\w+$/;
            if (!pattern.test(userName)) {
                $("#" + field + "_prompt_error").html("用户名只能输入由数字、26个英文字母或者下划线组成");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }

            get_request(function (value) {
                if (value == "true") {
                    $("#" + field + "_prompt_error").html("该用户名已存在");
                    $("#" + field + "_prompt_error").show();
                    $("#" + field + "_field_error").addClass("form-field-error");
                }
            },
                "userVerification.htm?userName=" + userName + "&timestamp=" + new Date().getTime(), true);


        }

        if (field == "mobile") {//手机号
            var mobile = $("#" + field).val().trim();
            if (mobile == "") {
                $("#" + field + "_prompt_error").html("手机号不能为空");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
            if (getStringLeng(mobile) < 11) {
                $("#" + field + "_prompt_error").html("手机号不正确");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }

            get_request(function (value) {
                if (value == "true") {
                    $("#" + field + "_prompt_error").html("手机号码已注册");
                    $("#" + field + "_prompt_error").show();
                    $("#" + field + "_field_error").addClass("form-field-error");
                }
            },
                "userVerification.htm?mobile=" + mobile + "&timestamp=" + new Date().getTime(), true);

        }
        if (field == "password") {//密码
            var password = $("#" + field).val().trim();
            if (password == "") {
                $("#" + field + "_prompt_error").html("密码不能为空");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
            if (getStringLeng(password) < 6) {
                $("#" + field + "_prompt_error").html("密码长度不能小于6位");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
            if (getStringLeng(password) > 20) {
                $("#" + field + "_prompt_error").html("密码长度不能大于20位");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
        }
        if (field == "confirmPassword") {//确认密码
            var confirmPassword = $("#" + field).val().trim();
            if (confirmPassword == "") {
                $("#" + field + "_prompt_error").html("确认密码不能为空");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }

            var password = $("#password").val().trim();
            if (confirmPassword != password) {
                $("#" + field + "_prompt_error").html("两次密码不相等");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
        }
        if (field == "issue") {//密码提示问题
            var issue = $("#" + field).val().trim();
            if (issue == "") {
                $("#" + field + "_prompt_error").html("提示问题不能为空");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
            if (getStringLeng(issue) < 6) {
                $("#" + field + "_prompt_error").html("提示问题长度不能小于6位");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
            if (getStringLeng(issue) > 30) {
                $("#" + field + "_prompt_error").html("提示问题长度不能大于30位");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
        }
        if (field == "answer") {//密码提示答案
            var answer = $("#" + field).val().trim();
            if (answer == "") {
                $("#" + field + "_prompt_error").html("提示答案不能为空");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
            if (getStringLeng(answer) < 6) {
                $("#" + field + "_prompt_error").html("提示答案长度不能小于6位");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
            if (getStringLeng(answer) > 30) {
                $("#" + field + "_prompt_error").html("提示答案长度不能大于30位");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
                return false;
            }
        }
        if (field == "email") {//邮箱
            var email = $("#" + field).val().trim();
            if (email != "") {
                if (getStringLeng(email) > 60) {
                    $("#" + field + "_prompt_error").html("邮箱地址不能超过60个字符");
                    $("#" + field + "_prompt_error").show();
                    $("#" + field + "_field_error").addClass("form-field-error");
                    return false;
                }
                var pattern = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
                if (!pattern.test(email)) {
                    $("#" + field + "_prompt_error").html("邮箱格式错误");
                    $("#" + field + "_prompt_error").show();
                    $("#" + field + "_field_error").addClass("form-field-error");
                    return false;
                }

            }
        }
        if (field == "smsCode") {//手机验证码
            var smsCode = $("#" + field).val().trim();
            if (smsCode == "") {
                $("#" + field + "_prompt_error").html("手机验证码不能为空");
                $("#" + field + "_prompt_error").show();
                $("#" + field + "_field_error").addClass("form-field-error");
            }
        }
        if (field == "captchaValue") {//验证码
            if (!$("#captchaValue_field").is(":hidden")) {//如果验证码框显示
                var captchaKey = $("#captchaKey").val().trim();
                var captchaValue = $("#" + field).val().trim();
                if (captchaValue == "") {
                    $("#" + field + "_prompt_error").html("验证码不能为空");
                    $("#" + field + "_prompt_error").show();
                    $("#" + field + "_field_error").addClass("form-field-error");
                    return false;
                }

                get_request(function (value) {
                    if (value == "false") {
                        $("#" + field + "_prompt_error").html("验证码错误");
                        $("#" + field + "_prompt_error").show();
                        $("#" + field + "_field_error").addClass("form-field-error");
                    }
                },
                    "userVerification.htm?captchaKey=" + captchaKey + "&captchaValue=" + captchaValue + "&timestamp=" + new Date().getTime(), true);

            }
        }
    }

    //更换验证码
    function replaceCaptcha() {
        var captchaKey = document.getElementById("captchaKey").value;
        document.getElementById("captcha").src = "captcha/" + captchaKey + ".jpg?" + Math.random();
    }


    //组装参数
    function getParameter() {
        var parameter = "";

        //url跳转参数
        var jumpUrl = getUrlParam("jumpUrl");
        if (jumpUrl != null) {
            parameter += "&jumpUrl=" + encodeURIComponent(jumpUrl);
        }
        //令牌标记
        var token = $("#token").val();
        parameter += "&token=" + token;

        //验证码Key
        parameter += "&captchaKey=" + encodeURIComponent($("#captchaKey").val());

        //验证码值
        parameter += "&captchaValue=" + encodeURIComponent($("#captchaValue").val());

        //用户类型
        if ($("#local_tab").find("a").hasClass("active")) {
            parameter += "&type=10";
            //用户名
            parameter += "&userName=" + encodeURIComponent($("#userName").val().trim());
        }
        if ($("#mobile_tab").find("a").hasClass("active")) {
            parameter += "&type=20";
            //手机号
            parameter += "&mobile=" + encodeURIComponent($("#mobile").val().trim());
        }


        //密码需SHA256加密
        var password = $("#password").val().trim();
        if (password != "") {
            parameter += "&password=" + CryptoJS.SHA256(password);
        }


        //密码提示问题
        parameter += "&issue=" + encodeURIComponent($("#issue").val().trim());

        //密码提示答案需SHA256加密
        var answer = $("#answer").val().trim();
        if (answer != "") {
            parameter += "&answer=" + CryptoJS.SHA256(answer);
        }

        //邮箱
        var email = $("#email").val().trim();
        if (email != "") {
            parameter += "&email=" + encodeURIComponent(email);
        }
        //手机验证码
        var smsCode = $("#smsCode").val().trim();
        if (smsCode != "") {
            parameter += "&smsCode=" + encodeURIComponent(smsCode);
        }


        //自动登录
        var rememberMe = $("input[id='rememberMe']:checked").val();
        if (rememberMe != null) {
            parameter += "&rememberMe=" + rememberMe;
        }

        //自定义表单name集合
        var array = new Array();

        //读取表单所有的input标签
        var all_input = document.getElementsByTagName("input");
        for (var i = 0; i < all_input.length; i++) {
            var obj = all_input[i];
            if (obj.name.substring(0, 11) == "userCustom_") {
                var isExist = false;//是否已存在数组中
                //如果存在，则不添加
                for (var j = 0; j < array.length; j++) {
                    if (array[j] == all_input[i].name) {
                        isExist = true;
                        break;
                    }
                }
                if (isExist == false) {
                    array.push(all_input[i].name);
                }
            }
        }
        //读取表单所有的select标签
        var all_select = document.getElementsByTagName("select");
        for (var i = 0; i < all_select.length; i++) {
            var obj = all_select[i];
            if (obj.name.substring(0, 11) == "userCustom_") {
                var isExist = false;//是否已存在数组中
                //如果存在，则不添加
                for (var j = 0; j < array.length; j++) {
                    if (array[j] == all_select[i].name) {
                        isExist = true;
                        break;
                    }
                }
                if (isExist == false) {
                    array.push(all_select[i].name);
                }
            }
        }
        //读取表单所有的textarea标签
        var all_textarea = document.getElementsByTagName("textarea");
        for (var i = 0; i < all_textarea.length; i++) {
            var obj = all_textarea[i];
            if (obj.name.substring(0, 11) == "userCustom_") {
                var isExist = false;//是否已存在数组中
                //如果存在，则不添加
                for (var j = 0; j < array.length; j++) {
                    if (array[j] == all_textarea[i].name) {
                        isExist = true;
                        break;
                    }
                }
                if (isExist == false) {
                    array.push(all_textarea[i].name);
                }
            }
        }

        for (var i = 0; i < array.length; i++) {
            //读取表单参数
            var obj = document.getElementsByName(array[i]);
            if (obj[0].type == "text") {//输入框
                parameter += "&" + obj[0].name + "=" + encodeURIComponent(obj[0].value);
            }

            if (obj[0].type == "radio") {//单选
                for (var j = 0; j < obj.length; j++) {
                    if (obj[j].checked) {
                        parameter += "&" + obj[0].name + "=" + obj[j].value;
                        break;
                    }
                }
            }
            if (obj[0].type == "checkbox") {//多选
                for (var j = 0; j < obj.length; j++) {
                    if (obj[j].checked) {
                        parameter += "&" + obj[0].name + "=" + obj[j].value;
                    }
                }
            }
            if (obj[0].type.substring(0, 6) == "select") {//下拉列表
                for (var j = 0; j < obj[0].length; j++) {
                    if (obj[0][j].selected) {
                        parameter += "&" + obj[0].name + "=" + obj[0][j].value;
                    }
                }
            }
            if (obj[0].type == "textarea") {//表单域
                parameter += "&" + obj[0].name + "=" + encodeURIComponent(obj[0].value);

            }
        }


        //删除第一个&号,防止因为多了&号而出现警告: Parameters: Invalid chunk ignored.信息
        if (parameter.indexOf("&") == 0) {
            parameter = parameter.substring(1, parameter.length);
        }
        return parameter;
    }

    //ajax提交
    function ajaxSubmit() {

        if (allVerification() == false) {
            //需引入layer
            layer.msg('请填好资料再提交', {
                    time: 1000 //1秒关闭（如果不配置，默认是1秒）
                }, function () {//关闭后的操作

                }
            );
            return;
        }

        var parameter = getParameter();
        if (parameter.indexOf("&") == 0) {
            parameter = parameter.substring(1, parameter.length);
        }

        post_request(function (value) {
            if (value != "") {
                var returnValue = JSON.parse(value);//JSON转为对象

                var value_success = "";
                var value_error = null;
                var value_jumpUrl = "";
                var value_captchaKey = null;
                for (var key in returnValue) {
                    if (key == "success") {
                        value_success = returnValue[key];
                    } else if (key == "error") {
                        value_error = returnValue[key];
                    } else if (key == "jumpUrl") {
                        value_jumpUrl = returnValue[key];
                    } else if (key == "captchaKey") {
                        value_captchaKey = returnValue[key];
                    }
                }
                if (value_success == "true") {//成功
                    window.location.href = (getBasePath() + value_jumpUrl);

                } else {//失败
                    for (var error in value_error) {
                        if (error != "") {
                            $("#" + error + "_prompt_error").html(value_error[error]);
                            $("#" + error + "_prompt_error").show();
                            $("#" + error + "_field_error").addClass("form-field-error");
                        }
                    }

                    if (value_captchaKey != null) {
                        $("#captchaValue_field").show();
                        //设置验证码Key
                        $("#captchaKey").val(value_captchaKey);

                        //设置验证码图片
                        replaceCaptcha();

                    }

                }
            }
        },
            "register?&timestamp=" + new Date().getTime(), true, parameter);

    }


    //验证全部参数
    function allVerification() {
        var isVerification = true;

        if ($("#local_tab").find("a").hasClass("active")) {
            if (verification("userName") == false) {
                isVerification = false;
            }
            if (verification("password") == false) {
                isVerification = false;
            }
            if (verification("confirmPassword") == false) {
                isVerification = false;
            }
            if (verification("issue") == false) {
                isVerification = false;
            }
            if (verification("answer") == false) {
                isVerification = false;
            }
            if (verification("captchaValue") == false) {
                isVerification = false;
            }
        }
        if ($("#mobile_tab").find("a").hasClass("active")) {
            if (verification("mobile") == false) {
                isVerification = false;
            }
            if (verification("password") == false) {
                isVerification = false;
            }
            if (verification("confirmPassword") == false) {
                isVerification = false;
            }
        }


        return isVerification;
    }


    //获取短信验证码
    function getSmsCode() {

        if ($("#smsCode_field_error").find("button").hasClass("btn-link-disabled")) {
            return;
        }

        var parameter = "";
        //令牌标记
        var token = $("#token").val();
        parameter += "&token=" + token;

        //模块
        parameter += "&module=100";

        parameter += "&mobile=" + encodeURIComponent($("#mobile").val().trim());

        //验证码Key
        parameter += "&captchaKey=" + encodeURIComponent($("#captchaKey").val());

        //验证码值
        parameter += "&captchaValue=" + encodeURIComponent($("#captchaValue").val());

        if (parameter.indexOf("&") == 0) {
            parameter = parameter.substring(1, parameter.length);
        }

        //清除错误信息
        $("#smsCode_prompt_error").html("");
        $("#smsCode_prompt_error").hide();
        $("#smsCode_field_error").removeClass("form-field-error");

        $("#smsCode_prompt_successInfo").html("");
        $("#smsCode_prompt_successInfo").hide();


        post_request(function (value) {
            if (value != "") {
                var returnValue = JSON.parse(value);//JSON转为对象
                var success = "false";

                for (var key in returnValue) {
                    if (key == "success") {
                        var success = returnValue[key];
                        if (success == "true") {
                            $("#smsCode_prompt_successInfo").html("短信验证码已发送");
                            $("#smsCode_prompt_successInfo").show();
                            //隐藏提交按钮60秒
                            var number = 60;//秒
                            var countdown = function () {
                                if (number == 0) {
                                    $("#smsCode_field_error").find("button").removeClass("btn-link-disabled");
                                    $("#smsCode_field_error").find("button").addClass("btn-link");
                                    $("#smsCode_field_error").find("button").text("获取验证码");
                                    number = 60;
                                    return;
                                } else {
                                    if ($("#smsCode_field_error").find("button").hasClass("btn-link")) {
                                        $("#smsCode_field_error").find("button").removeClass("btn-link");
                                        $("#smsCode_field_error").find("button").addClass("btn-link-disabled");
                                    }
                                    $("#smsCode_field_error").find("button").text(number + "秒后没收到可重新获取");
                                    number--;
                                }
                                setTimeout(countdown, 1000);
                            }
                            setTimeout(countdown, 0);

                        }
                    } else if (key == "error") {
                        var errorValue = returnValue[key];
                        for (var error in errorValue) {
                            if (error != "") {
                                $("#" + error + "_prompt_error").html(errorValue[error]);
                                $("#" + error + "_prompt_error").show();
                                $("#" + error + "_field_error").addClass("form-field-error");

                            }
                        }
                    } else if (key == "captchaKey") {//显示验证码
                        var captchaKey = returnValue[key];
                        if (captchaKey != "") {
                            //设置验证码Key
                            $("#captchaValue_field").show();
                            //设置验证码Key
                            $("#captchaKey").val(captchaKey);
                            //设置验证码图片
                            replaceCaptcha();
                        }
                    }
                }
            }
        },
            "smsCode?&timestamp=" + new Date().getTime(), true, parameter);
    }
</script>

<#--引入页脚-->
<@include action="${newPublic_3}"/>

</body>
</html>